<?php

class UserFilter extends CActiveRecord {

    public static function model($className = __CLASS__) {
        return parent::model($className);
    }

    public function tableName() {
        return 'UserFilter';
    }

    public function rules() {
        return array(
            array('name', 'length', 'max' => 50, 'min' => 3),
            array('tag_ids', 'safe'),
        );
    }

    public function getTagsText() {
        $criteria = new CDbCriteria();
        $criteria->addInCondition('id', explode(",", $this->tag_ids));
        $tags = Tags::model()->findAll($criteria);
        $tags_name = array();
        foreach($tags as $tag) $tags_name[] = $tag->name;
        return join(", ", $tags_name);
    }
}
